package com.kiki.album.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kiki.common.annotation.Log;
import com.kiki.common.core.controller.BaseController;
import com.kiki.common.core.domain.AjaxResult;
import com.kiki.common.enums.BusinessType;
import com.kiki.album.domain.Album;
import com.kiki.album.service.IAlbumService;
import com.kiki.common.utils.poi.ExcelUtil;
import com.kiki.common.core.page.TableDataInfo;

/**
 * 专辑信息Controller
 * 
 * @author 林志毅
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/album/album")
public class AlbumController extends BaseController
{
    @Autowired
    private IAlbumService albumService;

    /**
     * 查询专辑信息列表
     */
    @PreAuthorize("@ss.hasPermi('album:album:list')")
    @GetMapping("/list")
    public List<Album> list(Album album)
    {
        return albumService.selectAlbumList(album);
    }

    /**
     * 导出专辑信息列表
     */
    @PreAuthorize("@ss.hasPermi('album:album:export')")
    @Log(title = "专辑信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Album album)
    {
        List<Album> list = albumService.selectAlbumList(album);
        ExcelUtil<Album> util = new ExcelUtil<Album>(Album.class);
        util.exportExcel(response, list, "专辑信息数据");
    }

    /**
     * 获取专辑信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('album:album:query')")
    @GetMapping(value = "/{albumId}")
    public AjaxResult getInfo(@PathVariable("albumId") Long albumId)
    {
        return success(albumService.selectAlbumByAlbumId(albumId));
    }

    /**
     * 新增专辑信息
     */
    @PreAuthorize("@ss.hasPermi('album:album:add')")
    @Log(title = "专辑信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Album album)
    {
        return toAjax(albumService.insertAlbum(album));
    }

    /**
     * 修改专辑信息
     */
    @PreAuthorize("@ss.hasPermi('album:album:edit')")
    @Log(title = "专辑信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Album album)
    {
        return toAjax(albumService.updateAlbum(album));
    }

    /**
     * 删除专辑信息
     */
    @PreAuthorize("@ss.hasPermi('album:album:remove')")
    @Log(title = "专辑信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{albumIds}")
    public AjaxResult remove(@PathVariable Long[] albumIds)
    {
        return toAjax(albumService.deleteAlbumByAlbumIds(albumIds));
    }
}
